home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / c / syscall / RCS / Fs_Read.c,v < prev    next >
Encoding:
Text File  |  1991-12-09  |  3.3 KB  |  136 lines

  1. head     1.2;
  2. branch   ;
  3. access   ;
  4. symbols  sprited:1.2.1;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.2
  10. date     88.06.21.11.14.50;  author ouster;  state Exp;
  11. branches 1.2.1.1;
  12. next     1.1;
  13.  
  14. 1.1
  15. date     88.06.19.14.29.09;  author ouster;  state Exp;
  16. branches ;
  17. next     ;
  18.  
  19. 1.2.1.1
  20. date     91.12.08.17.04.47;  author kupfer;  state Exp;
  21. branches ;
  22. next     ;
  23.  
  24.  
  25. desc
  26. @@
  27.  
  28.  
  29. 1.2
  30. log
  31. @Cleanup header usage.
  32. @
  33. text
  34. @/* 
  35.  * Fs_Read.c --
  36.  *
  37.  *    Source code for the Fs_Read library procedure.
  38.  *
  39.  * Copyright 1988 Regents of the University of California
  40.  * Permission to use, copy, modify, and distribute this
  41.  * software and its documentation for any purpose and without
  42.  * fee is hereby granted, provided that the above copyright
  43.  * notice appear in all copies.  The University of California
  44.  * makes no representations about the suitability of this
  45.  * software for any purpose.  It is provided "as is" without
  46.  * express or implied warranty.
  47.  */
  48.  
  49. #ifndef lint
  50. static char rcsid[] = "$Header: Fs_Read.c,v 1.1 88/06/19 14:29:09 ouster Exp $ SPRITE (Berkeley)";
  51. #endif not lint
  52.  
  53. #include <sprite.h>
  54. #include <status.h>
  55. #include <fs.h>
  56.  
  57.  
  58. /*
  59.  *----------------------------------------------------------------------
  60.  *
  61.  * Fs_Read --
  62.  *
  63.  *      The "normal" Fs_Read routine for user code.  Read from the file
  64.  *      indicated by the stream id into the buffer.  bufSize indicates how
  65.  *      much data to read, and amountReadPtr is an output parameter that
  66.  *      indicates how much data were read.  A length of zero means
  67.  *      end-of-file.
  68.  *
  69.  *      If Fs_RawRead blocks to wait for data on the stream and a signal
  70.  *      is received by the process during the wait, then the system call
  71.  *      is aborted in order to process the signal.  When the signal has
  72.  *      been processed, the system call will return with a
  73.  *      GEN_ABORTED_BY_SIGNAL result, and *readCountPtr will have been
  74.  *      updated to reflect the number of bytes read so far.  This routine
  75.  *      will detect this condition and restart the system call to read the
  76.  *      remainder of the data.
  77.  *
  78.  * Results:
  79.  *    An error code.
  80.  *
  81.  * Side effects:
  82.  *    The read access pointer for the stream is advanced by
  83.  *    the amount of data read.
  84.  *
  85.  *----------------------------------------------------------------------
  86.  */
  87.  
  88. ReturnStatus
  89. Fs_Read(streamID, amountRead, buffer, amountReadPtr)
  90.     int        streamID;    /* The user's index into its open file list */
  91.     int        amountRead;    /* The amount of bytes to read */
  92.     Address    buffer;        /* The storage place for the read */
  93.     int        *amountReadPtr;    /* The amount of bytes actually read */
  94. {
  95.     int    realAmtRead;
  96.     ReturnStatus status;
  97.  
  98.     *amountReadPtr = 0;
  99.     do {
  100.     status = Fs_RawRead(streamID, amountRead, buffer, &realAmtRead);
  101.     *amountReadPtr += realAmtRead;
  102.     if (status == GEN_ABORTED_BY_SIGNAL) {
  103.         amountRead -= realAmtRead;
  104.         if (amountRead <= 0) {
  105.         return(SUCCESS);
  106.         }
  107.         buffer += realAmtRead;
  108.     }
  109.     } while (status == GEN_ABORTED_BY_SIGNAL);
  110.     return(status);
  111. }
  112. @
  113.  
  114.  
  115. 1.2.1.1
  116. log
  117. @Initial branch for Sprite server.
  118. @
  119. text
  120. @d17 1
  121. a17 1
  122. static char rcsid[] = "$Header: /sprite/src/lib/c/syscall/RCS/Fs_Read.c,v 1.2 88/06/21 11:14:50 ouster Exp $ SPRITE (Berkeley)";
  123. @
  124.  
  125.  
  126. 1.1
  127. log
  128. @Initial revision
  129. @
  130. text
  131. @d17 1
  132. a17 1
  133. static char rcsid[] = "$Header: proto.c,v 1.2 88/03/11 08:39:08 ouster Exp $ SPRITE (Berkeley)";
  134. d21 1
  135. @
  136.